package cn.edu.cuit.elena.web.tool;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TestServlet
    extends HttpServlet
{

    /**
     * Constructor of the object.
     */
    public TestServlet()
    {
        super();
    }

    /**
     * Destruction of the servlet. <br>
     */
    public void destroy()
    {
        super.destroy(); // Just puts "destroy" string in log
        // Put your code here
    }

    /**
     * The doGet method of the servlet. <br>
     * 
     * This method is called when a form has its tag value method equals to get.
     * 
     * @param request
     *            the request send by the client to the server
     * @param response
     *            the response send by the server to the client
     * @throws ServletException
     *             if an error occurred
     * @throws IOException
     *             if an error occurred
     */
    public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException
    {
        doPost( request, response );
    }

    /**
     * The doPost method of the servlet. <br>
     * 
     * This method is called when a form has its tag value method equals to post.
     * 
     * @param request
     *            the request send by the client to the server
     * @param response
     *            the response send by the server to the client
     * @throws ServletException
     *             if an error occurred
     * @throws IOException
     *             if an error occurred
     */
    public void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException
    {

        response.setContentType( "text/html" );
        PrintWriter out = response.getWriter();
        String dataString = "[{\"appeId\":\"1\",\"survId\":\"1\",\"location\":\"\",\"surveyDate\":\"2008-03-14\",\"surveyTime\":\"12:19:47\",\"inputUserId\":\"1\",\"inputTime\":\"2008-03-14 12:21:51\",\"modifyTime\":\"0000-00-00 00:00:00\"},{\"appeId\":\"2\",\"survId\":\"32\",\"location\":\"\",\"surveyDate\":\"2008-03-14\",\"surveyTime\":\"22:43:09\",\"inputUserId\":\"32\",\"inputTime\":\"2008-03-14 22:43:37\",\"modifyTime\":\"0000-00-00 00:00:00\"},{\"appeId\":\"3\",\"survId\":\"32\",\"location\":\"\",\"surveyDate\":\"2008-03-15\",\"surveyTime\":\"07:59:33\",\"inputUserId\":\"32\",\"inputTime\":\"2008-03-15 08:00:44\",\"modifyTime\":\"0000-00-00 00:00:00\"},{\"appeId\":\"4\",\"survId\":\"1\",\"location\":\"\",\"surveyDate\":\"2008-03-15\",\"surveyTime\":\"10:45:42\",\"inputUserId\":\"1\",\"inputTime\":\"2008-03-15 10:46:04\",\"modifyTime\":\"0000-00-00 00:00:00\"},{\"appeId\":\"5\",\"survId\":\"32\",\"location\":\"\",\"surveyDate\":\"2008-03-16\",\"surveyTime\":\"08:04:49\",\"inputUserId\":\"32\",\"inputTime\":\"2008-03-16 08:05:26\",\"modifyTime\":\"0000-00-00 00:00:00\"},{\"appeId\":\"6\",\"survId\":\"32\",\"location\":\"\",\"surveyDate\":\"2008-03-20\",\"surveyTime\":\"20:19:01\",\"inputUserId\":\"32\",\"inputTime\":\"2008-03-20 20:19:32\",\"modifyTime\":\"0000-00-00 00:00:00\"}]";
        out.write( dataString );
        out.flush();
        out.close();
    }

    /**
     * Initialization of the servlet. <br>
     * 
     * @throws ServletException
     *             if an error occurs
     */
    public void init() throws ServletException
    {
        // Put your code here
    }

}
